home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / zcpp_jae.zip / MACROSAM.C < prev    next >
C/C++ Source or Header  |  1990-07-10  |  1KB  |  64 lines

  1. /*
  2.  
  3.  
  4.  Copyright (C) 1990 Texas Instruments Incorporated.
  5.  
  6.  Permission is granted to any individual or institution to use, copy, modify,
  7.  and distribute this software, provided that this complete copyright and
  8.  permission notice is maintained, intact, in all copies and supporting
  9.  documentation.
  10.  
  11.  Texas Instruments Incorporated provides this software "as is" without
  12.  express or implied warranty.
  13.  
  14. */
  15.  
  16. #pragma defmacro MACRO "macro" delimiter=}
  17.  
  18.  
  19. //
  20. // Example 1
  21. //
  22.  
  23. MACRO set_val (size, value=0, KEY: low = 0, high = 100) {
  24.  set_val_internal(size, value, low, high-low)
  25. }
  26.  
  27. set_val(5)
  28. set_val(foo, 2, low=5)
  29. set_val(bar, baz, high=95)
  30.  
  31.  
  32. //
  33. // Example 2
  34. //
  35.  
  36. MACRO build_table (name, REST: rest) {
  37.  char* name[] = { build_table_internal(rest) NULL }
  38. }
  39.  
  40. MACRO build_table_internal (first, REST: rest=count) {
  41.  #first,
  42.  #if count
  43.  build_table_internal(rest)
  44.  #endif
  45. }
  46.  
  47. build_table(table, 1, 2, 3, 4, 5, 6, 7);
  48.  
  49.  
  50. //
  51. // Example 3
  52. //
  53.  
  54. MACRO LOOP (type, variable, sequence, BODY: body) {
  55.  { type variable;
  56.    for (sequence.reset; sequence.next;)
  57.        { variable = sequence.value();
  58.          body
  59.        }
  60.  }
  61. }
  62.  
  63. LOOP (char, elt, list) { print(elt) }
  64.